com.cete.dynamicpdf
Class Page
Example : The following example shows how to use go to action.
import com.cete.dynamicpdf.*;
import com.cete.dynamicpdf.pageelements.*;
import com.cete.dynamicpdf.pageelements.forms.*;
public class MyClass {
public static void main(String args[]) {
// Create a PDF Document
Document document = new Document();
// Create pages and add it to the document
Page page = new Page();
Page page1 = new Page();
document.getPages().add(page);
document.getPages().add(page1);
Button button = new Button("btn", 50, 150, 100, 30);
button.setLabel("Click Here");
// Create labels
Label label1 = new Label("Click the button to go to the second page :", 50, 100, 300, 30);
Label label2 = new Label("This is the second page :", 50, 100, 200, 30);
// Add the labels and button to the page
page.getElements().add(button);
page.getElements().add(label1);
page1.getElements().add(label2);
// Create a goto action and assign to the button events.
GoToAction action = new GoToAction(2, PageZoom.FIT_WIDTH);
button.getReaderEvents().setMouseUp(action);
// Save the PDF
document.draw( "[physicalpath]/MyDocument.pdf" );
}
}